package com.android.lib.base.network.interceptors

import com.android.lib.base.manager.MMKVManager
import com.blankj.utilcode.util.AppUtils
import okhttp3.Interceptor
import okhttp3.Response

/**
 * author : yzp
 * desc   : 添加通用header拦截器
 */
class HeaderInterceptor : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val builder = chain.request().newBuilder()
//client-id	是	当前产品号，默认传07（子产品传appSsid）
//token	否	登录令牌，登录时获取
//userId	否	用户ID，登录时获取（子产品传curUserId）
//currentUserId	否	当前用户ID，子产品传curUserId
//channel	是	频道，默认传googleplay
//versionName	是	版本名
//versionCode	是	版本号
//device-id	是	设备ID
//imei	是	设备识别码
//mulFlag	是	多产品标识，默认传1
//v-flag	否	登录标识，默认传空（不需要登录的接口传true）
        //    "blankClothesValuableNewTent": "time",
        //    "severalBlueFrontier": "apiName",
        //    "thisTrousersQuickProductionSculpture": "channel",
        //    "changeableShineMerchantInstructionSaltyAustralia": "versionName",
        //    "rawBraveActress": "versionCode",
        //    "chineseKeyNorthernFrequentList": "deviceId",
        //    "standardPondStrictSufferingNursery": "imei",
        //    "hillyMatchSurroundingDictionary": "client-id",
        //    "bestFingernailProbableDialogueHarmlessMainland": "appssid",
        //    "nearbyStewardessHalfThere": "currentUserId",
        //    "russianGasStrictSteam": "userId",
        //    "irishPacificPotato": "token",
        //    "agriculturalTomb": "device-id",
        //    "boundHam": "v-flag",
        //    "commonMomAntarcticEverydayHero": "mulFlag",
        //    "electricalPartGladPhotograph": "signature",
        //    "cleverPhotoSpareSouthCoke": "type",
        //    "conceitedHair": "client-id",
        //    "madSimpleSilk": "v-flag",
        //    "livingUnimportantFingernail": "device-id"
        builder.addHeader("conceitedHair", "202")
        builder.addHeader("irishPacificPotato", MMKVManager.decodeString("token"))
        builder.addHeader("russianGasStrictSteam", MMKVManager.decodeString("userID"))
//        builder.addHeader("nearbyStewardessHalfThere", "22222222")
        builder.addHeader("thisTrousersQuickProductionSculpture", "google")
        builder.addHeader("changeableShineMerchantInstructionSaltyAustralia",  AppUtils.getAppVersionName())
        builder.addHeader("rawBraveActress", AppUtils.getAppVersionCode().toString())
        builder.addHeader("livingUnimportantFingernail", "deviceId")
        builder.addHeader("standardPondStrictSufferingNursery", "deviceId")
        builder.addHeader("commonMomAntarcticEverydayHero", "mulFlag")
        val request = builder.build()
        return chain.proceed(request)
    }
}